<template>
  <div class="app-container">
    <div class="tool-bar" style="margin: 0px 0px 10px 0px">
      <el-button type="primary" size="mini" @click="addTemplate">新增学习模块</el-button>
    </div>
    <el-table
      v-loading="loading"
      element-loading-text="请稍后"
      size="mini"
      :data="list"
      border
      style="width: 100%"
    >
      <el-table-column
        type="index"
        width="50"
      />
      <el-table-column
        prop="templateName"
        align="center"
        label="模板名称"
      />
      <el-table-column
        prop="operatorName"
        align="center"
        label="创建人"
      />
      <el-table-column
        prop="createDate"
        align="center"
        label="创建时间"
      />
      <el-table-column
        prop="deptName"
        align="center"
        label="创建人部门"
      />
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            size="mini"
            @click="detail(scope.$index, scope.row)"
          >查看详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
    >
      <span>这是一段信息</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { getTemplateList } from '@/api/template'
export default {
  data() {
    return {
      list: [],
      dialogVisible: false
    }
  },
  mounted() {
    this.initData()
  },
  methods: {
    initData() {
      getTemplateList().then(res => {
        this.list = res.data
      })
    },
    detail(index, row) {
      this.$router.push('/config/detail/' + row.id)
    },
    addTemplate() {

    }
  }
}
</script>
